package com.cykj.service.impl;

import com.cykj.mapper.VisitDoctorMapper;
import com.cykj.pojo.CyCombination;
import com.cykj.pojo.CyVisitDoctor;
import com.cykj.service.VisitDoctorService;
import com.cykj.util.PageResult;
import com.cykj.util.PageUtils;
import com.cykj.util.ResponseDto;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VisitDoctorServiceImpl implements VisitDoctorService {
    @Autowired
    private VisitDoctorMapper visitDoctorMapper;
    @Override
    public ResponseDto addInfo(String id, String projectName, String orderExaminationId) {
        int i = visitDoctorMapper.addInfo(id, projectName, orderExaminationId);
        return new ResponseDto(1,"添加成功",null);
    }

    @Override
    public ResponseDto perfectInfo(int adminId, String summary, String proName) {
        int i = visitDoctorMapper.perfectInfo(adminId, summary, proName);
        return new ResponseDto(1,"体检小结写入成功",i);
    }

    @Override
    public ResponseDto selectSummary(String name) {
        String s = visitDoctorMapper.selectSummary(name);
        if (s == null){
            return new ResponseDto(1,"暂未写",null);
        }else{
            return new ResponseDto(1,"体检小结查询成功",s);
        }
    }

    @Override
    public ResponseDto getAllInfo(int finish,int pageCurr, int pageSize) {
        Page<Object> page = PageHelper.startPage(pageCurr, pageSize);
        List<CyVisitDoctor> allInfo = visitDoctorMapper.getAllInfo(finish);
        if (allInfo != null) {
            visitDoctorMapper.statusTimer();
            PageInfo<Object> pageInfo = new PageInfo<>(page);
            PageResult pageResult = PageUtils.getPageResult(pageInfo);
            return new ResponseDto(1,"体检小结查询成功",pageResult);
        } else {
            return new ResponseDto(0, "查询失败", null);
        }

    }
}
